package february.test_2_27;

import java.util.Scanner;

public class TestMain1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int y = scanner.nextInt();
        int m = scanner.nextInt();
        int d = scanner.nextInt();
        Boolean tmp = isRunnian(y);
        int h = addMonth(tmp,m);
        System.out.println(h+d);
    }
    public static Boolean isRunnian(int y) {
        if(y % 400 == 0) {
            return true;
        } else if(y % 4 == 0 && y % 100 != 0){
            return true;
        } else {
            return false;
        }
    }
    public static int addMonth(Boolean tmp,int m) {
        int h = 0;
        for(int i = 1; i < m; i++) {
            if(i == 2 && tmp) {
                h += 29;
            } else if(i == 2 && !tmp) {
                h += 28;
            }else if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) {
                h += 31;
            } else {
                h += 30;
            }
        }
        return h;
    }
}
